package org.wattdepot.cli.command;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the help method with various inputs for correct outputs.
 * 
 * @author Alex Kan and Kelvin Green
 * @version 2.0
 */
public class TestWattDepotHelp {

  WattDepotCommand commandInstance;
  String[] commandArray;
  String userInput;

  /**
   * Test the WattDepotHelp command for correct outputs.
   * 
   * Test (correct) help: source {source} summary. Test (correct) help: dailysensordata {source} day
   * {day} Test (failed) help 1: Correct command is help
   */
  @Test
  public void testHelp() {
    WattDepotCommand.connect("http://server.wattdepot.org:8182/wattdepot/");

    commandInstance = new WattDepotHelpCommand();
    userInput = "help";
    commandArray = userInput.split(" ");
    assertTrue("Check for help", commandInstance.doCommand(commandArray).contains(
        "source {source} summary"));

    userInput = "help";
    commandArray = userInput.split(" ");
    assertTrue("Check for help", commandInstance.doCommand(commandArray).contains(
        "dailysensordata {source} day {day}"));

    userInput = "help 1";
    commandArray = userInput.split(" ");
    assertTrue("Check for help 1 error", commandInstance.doCommand(commandArray).contains(
        "Correct command is help"));
  }

}